Hardened Malloc/Manual Installation
Install Hardened Malloc[edit]
Users of Linux distributions that are not based on Debian must compile Hardened Malloc from source. [1] To do this, it is necessary to install g++ for compilation.
1. Update the package lists.
sudo apt update
2. Install g++
, and git
to clone the repository.
sudo apt install g++ git
3. The following block explains how to download and signature verify hardened malloc.
Run the following commands in a terminal to download and verify the signing key and source code.
Retrieve the signing key. [2]
scurl-download https://github.com/thestinger.gpg
Verify the key fingerprint.
gpg --keyid-format long --with-fingerprint thestinger.gpg
Should show.
gpg: WARNING: no command supplied. Trying to guess what you mean ...
pub rsa4096/F9E712E59AF5F22A 2012-12-06 [SC]
Key fingerprint = 65EE FE02 2108 E2B7 08CB FCF7 F9E7 12E5 9AF5 F22A
uid Daniel Micay <danielmicay@gmail.com>
uid Daniel Micay <daniel.micay@copperhead.co>
uid Daniel Micay <security@attestation.app>
uid Daniel Micay <security@seamlessupdate.app>
uid Daniel Micay <security@grapheneos.org>
sub rsa4096/7363D2F61FDC8A7F 2012-12-06 [E]
Import the key.
gpg --import thestinger.gpg
Get the source code.
git clone https://github.com/GrapheneOS/hardened_malloc
Navigate to the hardened_malloc
folder.
cd hardened_malloc
Always verify software signatures! Check the hardened malloc signature.
git tag --verify 8
Should show.
object d80919fa1e8042a070a3f9b2560ff2ecac8a75da
type commit tag 8 tagger Daniel Micay <danielmicay@gmail.com> 1562939118 -0400
8 gpg: Signature made Fri 12 Jul 2019 09:45:21 AM EDT gpg: using RSA key 65EEFE022108E2B708CBFCF7F9E712E59AF5F22A gpg: issuer "danielmicay@gmail.com" gpg: Good signature from "Daniel Micay <danielmicay@gmail.com>" [unknown] gpg: aka "Daniel Micay <security@attestation.app>" [unknown] gpg: aka "Daniel Micay <security@seamlessupdate.app>" [unknown] gpg: aka "Daniel Micay <security@grapheneos.org>" [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 65EE FE02 2108 E2B7 08CB FCF7 F9E7 12E5 9AF5 F22A
4. Checkout the tag.
git checkout 8
5. Build the program.
This will only take a few seconds, depending on your system's resources.
make
6. Move the hardened_malloc library to the system library folder
Create folder /usr/lib/libhardened_malloc.so
sudo mkdir -p /usr/lib/libhardened_malloc.so
Move the library.
sudo mv libhardened_malloc.so /usr/lib/x86_64-linux-gnu/libhardened_malloc-light.so
7. Set SUID (set-user-id
).
sudo chmod u+s /lib/x86_64-linux-gnu/libhardened_malloc.so
8. Done.
Installation of Hardened Malloc has been completed.
How-to: Launch Applications with Hardened Malloc[edit]
Systemd Services[edit]
To launch individual systemd services with hardened malloc, add drop a systemd configuration snippet.
Environment="LD_PRELOAD='libhardened_malloc.so'"
Other Applications[edit]
To launch other applications with Hardened Malloc, the LD_PRELOAD
environment variable must be edited before starting the application. For example, to launch application-name
in this way, run.
LD_PRELOAD='libhardened_malloc.so' application-name
All Applications by Default[edit]
Note: This action may break numerous applications such as man, apt or Xorg.
It is possible to make all applications use Hardened Malloc as the default memory allocator. To configure this option, the path to the hardened_malloc.so
library must be added to the /etc/ld.so.preload
file.
1.
Open file /etc/ld.so.preload
in an editor with root rights.
Kicksecure
See
Open File with Root Rights
for detailed instructions on why to use sudoedit
for better security and how to use it.
sudoedit /etc/ld.so.preload
Kicksecure for Qubes
NOTES:
- When using Kicksecure-Qubes, this needs to be done inside the Template.
sudoedit /etc/ld.so.preload
- After applying this change, shutdown the Template.
- All App Qubes based on the Template need to be restarted if they were already running.
- This is a general procedure required for Qubes and unspecific to Kicksecure for Qubes.
Others and Alternatives
- This is just an example. Other tools could achieve the same goal.
- If this example does not work for you or if you are not using Kicksecure, please refer to this link.
sudoedit /etc/ld.so.preload
2. Add the hardened_malloc.so
library.
libhardened_malloc.so
3. Save the file.
The procedure is complete.
Footnotes[edit]
- ↑ Hardened Malloc is available form the Kicksecure APT repository for Debian-based distributions.
- ↑ https://grapheneos.org/install https://github.com/GrapheneOS/hardened_malloc/issues/82
- ↑
We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 12 year success story and maybe DONATE!